CREATE TABLE [dbo].[TblFiles]
(
[ID] [uniqueidentifier] NOT NULL,
[TaskId] [uniqueidentifier] NULL,
[FileName] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Date] [datetime] NULL,
[OriginalFileName] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[UserId] [uniqueidentifier] NULL,
[DocId] [uniqueidentifier] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
ALTER TABLE [dbo].[TblFiles] ADD
CONSTRAINT [FK_TblFiles_TblDocuments1] FOREIGN KEY ([DocId]) REFERENCES [dbo].[TblDocuments] ([ID])
ALTER TABLE [dbo].[TblFiles] ADD
CONSTRAINT [FK_TblFiles_aspnet_Users] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Users] ([UserId]) ON DELETE SET NULL ON UPDATE SET NULL
ALTER TABLE [dbo].[TblFiles] WITH NOCHECK ADD
CONSTRAINT [FK_TblFiles_TblTasks] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[TblTasks] ([ID]) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[TblFiles] ADD CONSTRAINT [PK_TblFiles] PRIMARY KEY CLUSTERED  ([ID]) ON [PRIMARY]
GO
